<template>
  <section class="jumbotron">
      <h3 class="jumbotron-heading">搜索gihub用户</h3>
      <div>
        <input type="text" placeholder="输入用户名去搜索" v-model="keyword"/>&nbsp;
        <button @click="search">搜索</button>
      </div>
    </section>
</template>

<script>
  import axios from 'axios'
  export default {
    name:'Search',
    data() {
      return {
        keyword:''
      }
    },
    methods: {
      async search(){
        try {
          let result = await axios.get(`https://api.github.com/search/users?q=${this.keyword}`)
          this.$bus.$emit('user-list',result.data.items)
        } catch (error) {
          alert(error.message)
        }
      }
    },
  }
</script>

<style scoped>
  
</style>